<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>Save the Beans</title>
    <link rel="stylesheet" href="style.css">
    <style>
        /* 直接在HTML中添加样式，确保封面图片可以被正确隐藏 */
        .game-cover.hidden, 
        .game-cover[style*="display: none"] {
            display: none !important;
            visibility: hidden !important;
            opacity: 0 !important;
            z-index: -1 !important;
        }
        
        .game-view {
            position: relative !important;
        }
        
        /* 添加白底黑线风格的样式 */
        body {
            background-color: #fff;
            color: #000;
            touch-action: manipulation; /* 防止双击缩放 */
        }
        
        canvas {
            background-color: #fff !important;
            border: 1px solid #000 !important;
        }
        
        /* 移动设备上的触摸控制 */
        .mobile-controls {
            display: none;
            width: 100%;
            padding: 15px;
            background-color: #f5f5f5;
            border-top: 1px solid #000;
            flex-direction: column;
            align-items: center;
            gap: 15px;
        }
        
        @media (max-width: 768px) {
            .mobile-controls {
                display: flex;
            }
        }
        
        .control-btn {
            width: 70px;
            height: 70px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 50%;
            font-size: 28px;
            display: flex;
            justify-content: center;
            align-items: center;
            user-select: none;
            -webkit-user-select: none;
            touch-action: manipulation;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            cursor: pointer;
        }
        
        .control-btn:active {
            background-color: #45a049;
            transform: scale(0.95);
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        }
        
        .horizontal-controls {
            display: flex;
            gap: 20px;
        }
    </style>
</head>
<body>
    <div class="game-container">
        <div class="game-banner">
            <img src="assets/images/game_banner.png" alt="Save the Beans" id="gameBanner">
        </div>
        <div class="game-info">
            <div class="score-display">
                <h2>得分: <span id="score">0</span> | 被吃掉豆子: <span id="beans-count">0</span></h2>
            </div>
            <div class="timer-display">
                <h2>时间: <span id="timer">30</span>秒</h2>
            </div>
            <div class="button-container">
                <button id="startButton">开始</button>
                <button id="restartButton" style="display: none;">重新开始</button>
            </div>
        </div>
        
        <div class="game-view">
            <img src="assets/images/fm.png" alt="Game Cover" id="gameCover" class="game-cover">
            <canvas id="gameCanvas" width="800" height="600"></canvas>
        </div>
        
        <!-- 移动设备触摸控制 -->
        <div class="mobile-controls">
            <button class="control-btn" id="upBtn">↑</button>
            <div class="horizontal-controls">
                <button class="control-btn" id="leftBtn">←</button>
                <button class="control-btn" id="rightBtn">→</button>
            </div>
            <button class="control-btn" id="downBtn">↓</button>
        </div>
        
        <div class="controls">
            <p>使用方向键或WASD控制幽灵移动，阻止吃豆人吃掉一半以上的豆子！</p>
        </div>
        
        <!-- 添加关于游戏按钮 -->
        <div class="about-container">
            <button id="aboutButton">关于游戏</button>
        </div>
        
        <!-- 游戏结束弹窗 -->
        <div id="gameOver" class="game-over-modal" style="display: none;">
            <div class="game-over-content">
                <button class="close-button" id="closeGameOver">&times;</button>
                <div id="gameOverContent"></div>
                <button id="gameOverRestartButton" class="restart-button">重新开始</button>
            </div>
        </div>
        
        <div id="congratsMessage" class="congrats-message" style="display: none;">
            <div class="congrats-content">
                <h2>恭喜你！</h2>
                <p>你已经成功保护了足够多的豆子，达到了目标分数！</p>
                <p>继续努力，挑战更高分数！</p>
                <button id="congratsCloseButton">关闭</button>
            </div>
        </div>
        
        <!-- 添加关于游戏弹窗 -->
        <div id="aboutModal" class="about-modal">
            <div class="about-content">
                <button class="close-button" id="closeAboutModal">&times;</button>
                <h2>关于游戏</h2>
                <p><strong>游戏说明：</strong>灵感来自于吃豆人游戏，贪吃的吃豆人老是吃不够，小豆子好可怜。小幽灵是保护豆子的，游戏就是保护豆子不让吃豆人吃了。</p>
                <div class="credits">
                    <p><strong>创意：</strong>侯时与</p>
                    <p><strong>美术：</strong>侯时与</p>
                    <p><strong>代码：</strong>AI-deepseek</p>
                    <p><strong>学校：</strong>浐灞一小创新小学一年级15班</p>
                </div>
            </div>
        </div>
    </div>
    <script src="game.js"></script>
    
    <!-- 添加关于游戏弹窗的JavaScript -->
    <script>
        // 获取关于游戏按钮和弹窗元素
        const aboutButton = document.getElementById('aboutButton');
        const aboutModal = document.getElementById('aboutModal');
        const closeAboutModal = document.getElementById('closeAboutModal');
        
        // 点击关于游戏按钮显示弹窗
        aboutButton.addEventListener('click', function() {
            aboutModal.style.display = 'flex';
        });
        
        // 点击关闭按钮隐藏弹窗
        closeAboutModal.addEventListener('click', function() {
            aboutModal.style.display = 'none';
        });
        
        // 点击弹窗外部区域隐藏弹窗
        aboutModal.addEventListener('click', function(event) {
            if (event.target === aboutModal) {
                aboutModal.style.display = 'none';
            }
        });
    </script>
</body>
</html>